//
//  MyDisabledButton.cpp
//  CanYouDoIt
//
//  Created by hoangtx on 7/13/13.
//
//

#include "MyDisabledButton.h"


bool MyDisabledButton::init(){
    MySpriteButton::init();
    
    return true;
}

void MyDisabledButton::setEnable(bool mEnable){
    isEnabled = mEnable;
    updateState();
}

MyDisabledButton* MyDisabledButton::create(const char *fileName, double mX, double mY, double mWidth, double mHeight){
    MyDisabledButton* button = MyDisabledButton::create();
    button->setPosition(ccp(mX,mY));
    button->buttonSize = CCSizeMake(mWidth, mHeight);
    button->sprite = CCSprite::create(fileName);
    button->sprite->setAnchorPoint(ccp(0,0));
    button->sprite->setScaleX(mWidth/button->sprite->getContentSize().width);
    button->sprite->setScaleY(mHeight/button->sprite->getContentSize().height);
    button->sprite->setPosition(ccp(0,0));
    button->sprite->setColor(button->normalColor);
    button->addChild(button->sprite);
    button->setEnable(true);
    return button;
}

void MyDisabledButton::goToDisabledMode(){
    sprite->setColor(ccc3(200,200,200));
}
void MyDisabledButton::updateState(){
    if(isEnabled){
        if(isFocused){
            goToHighlightMode();
        }else{
            goToNormalMode();
        }
    }else{
        goToDisabledMode();
    }
}

bool MyDisabledButton::isTouchedAt(cocos2d::CCPoint touchPosition){
    //if(isEnabled){
        return MySpriteButton::isTouchedAt(touchPosition);
    //}else{
    //    return false;
    //}
}

